#cs -------CREATE FILE DOC USING MICROSOFT WORD---------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         myName

 Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
$strType= "Word 97-2003 Document"
$pathFolder = "D:\Auto-doc.doc"

ShellExecute("winword.exe")
WinWaitActive("Document1 - Microsoft Word")
WinActivate("Document1 - Microsoft Word")
WinSetState("Document1 - Microsoft Word","",@SW_MAXIMIZE)
Sleep(300)
MouseClick( "left",300,300)
Send("This is a text")
Sleep(200)
Send("^s")
WinWaitActive("Save As")
WinActivate("Save As")
;WinWaitActive("Save As")
$text2 = WinGetText("Save As")
ConsoleWrite("text = "&$text2)
sleep(300)
;$initPath = "C:\Users\LoanHuynh\Documents"
;FileSaveDialog("Save As",$initPath,"*.doc",2,$pathFolder)
;ControlClick("Save As","Word Document","[CLASS:ComboBox2; INSTANCE:2]")

ControlCommand("Save As","Word Document","[CLASS:ComboBox; INSTANCE:2]","ShowDropDown")
Send("{SHIFTDOWN}",1)
AutoItSetOption("SendKeyDelay",10)
;Sleep(500)
; Search File Type
For $i = 1 To 2 Step 1
   Send("{SHIFTDOWN}",1)
   AutoItSetOption("SendKeyDelay",20)
   Send("{ESC}",1)
   $text = WinGetText("Save As")
   ConsoleWrite("text = "& $text)
   Sleep(200)
   ConsoleWrite("***************")
   If StringInStr($text,$strType,0)<>0 Then
	  ConsoleWrite("found: " &StringInStr($text,$strType,0))
	  ExitLoop
   Else
	  ControlCommand("Save As","Word Document","[CLASSNAMENN:ComboBox2]","ShowDropDown")
	  Send("{SHIFTDOWN}",1)
	  Opt("SendKeyDelay",10)
   EndIf
Next
#cs
WinActivate("Save As")
ControlClick("[TITLE:SaveAs; CLASS:#32770]","This is a text","[CLASS:Edit; INSTANCE:1]")
Send("^a")
Send("{DEL}")
Send($pathFolder)
Sleep(500)
WinWaitActive("Save As","&Save")
ControlClick("Save As","&Save", "[CLASS:Button; INSTANCE:8]")
Send("{ALT}")
Send("fx")
#ce
